<%@ page import="com.ecomm.session.SessionMng,
com.ecomm.util.Tree,
java.util.Enumeration,
com.ecomm.util.TreeNode,
com.ecomm.security.functiontree.FunctionInfo,
com.ecomm.util.Config,
java.io.OutputStream,
java.io.Writer,
java.io.IOException,
java.util.Collection,
com.ecomm.util.*,
com.ecomm.oa.accredit.*,
com.ecomm.message.profile.IAlertProfileManager,
com.ecomm.message.profile.DefaultAlertProfileManager,
com.ecomm.message.profile.AlertProfile,
com.ecomm.message.profile.IAlertStatus"%>
<%@page contentType="text/html;charset=utf-8"%>
<script language='javascript'>
      function openChat(){
     window.open("<%=request.getContextPath()%>/chat/index.jsp","openChat", "status=no,resizable=yes,scrollbars=no,toolbar=no,WIDTH=220,HEIGHT=600")
     }
</script>
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
<!-- 一级菜单的开始 -->
<table border="0" cellpadding="0"  class="menuBar">
  <tr>
    <td class="menuBar_left"><span class="handbtn"></span></td>
    <%
    //上下文路径
    
    
    String ctxp = request.getContextPath();
    
    SessionMng sessionMng=(SessionMng)session.getAttribute("sessionmng");
    String sThemeImagePath=ctxp+Config.getString("theme.newstyle.imagepath","")+"/";
    
    TreeNode node=null;
    FunctionInfo info=null;
    Tree tree = null;
    String sFlag = (String)session.getAttribute("originalLoginUserId");
    
    if(sFlag==null) {
      tree=sessionMng.getFunctionTree();
    } else {
      DB db = null;
      try {
        db = DBFactory.getDBInstance();
        AccreditAcl accreditAcl = new AccreditAcl(db);
        String accreditUserId = AccreditUtil.getStringValueByFieldName("select id from ORGMODEL_USERINFO where loginname='"+sFlag+"'","id",db);
        tree = accreditAcl.AclToTree(accreditAcl.getFunctionTree(false,true,false,sessionMng.getUserInfo().getID(),accreditUserId,new String[]{"using"},"user"));
        db.close();
      } catch(Exception e) {
      }
      
    }
    
    Enumeration enuChild=tree.getRoot().children();
    int nCount=0;
    while(enuChild.hasMoreElements()) {
      node=(TreeNode)enuChild.nextElement();
      info=(FunctionInfo)node.getUserObject();
      
      if(nCount!=0) {
        out.println("<td><span class='sepbtn'></span></td>");
      }
    
    %>
    
    <td align="center" nowrap>
      <table cellpadding="0" cellspacing="0" class="root" >
        <%
        
        %>
        <tr>
          <td class="left"></td>
          <%
          if(!"".equals(info.getImage())) {
        out.print("<td class='icon'>");
        if("menu".equals(info.getType())||"".equals(Function.normalizeString(info.getType())))    //如果类型是菜单类型，则取得子菜单
        {
          out.print("<a href='#' id='"+info.getId()+"' >");
        } else                        //否则直接输出地址
        {
          out.print("<a href='"+ctxp+"/menucontroller.do?functionid="+info.getId()+"' id='"+info.getId()+"' target='contentFrame'>");
        }
        out.print("<img border=0 src='"+ctxp+info.getImage()+"'>");
        out.print("</a>");
        out.print("</td>");
        
          } else {
        out.print("<td class='icon'></td>");
          }
          
          %>
          <td class="middle" nowrap><%=info.getName()%></td>
          <td class="right"></td>
        </tr>
        <%
        
        
        %>
      </table>
      
    </td>
    <%
    nCount++;
    }
    
    boolean bAccreditLogin = session.getAttribute("originalLoginUserId") != null && session.getAttribute("originalLoginPassword") != null;
    if(bAccreditLogin){
    %>
    
    <td><span class=sepbtn></span></td>
    <td align="center" nowrap>
      <!-- D菜单的开始 -->
      <table cellspacing="0" cellpadding="0" class="root" menu="logoutAccredit">
        <a href='<%=ctxp%>/oa/accredit/accredittree/accreditmng_logout.jsp' target="_top">
          <tr>
            <td class="left"></td>
            <td class="icon"><img src="<%=sThemeImagePath%>mac.gif" width="18" height="18"></td>
            <td class="middle"  nowrap >委派返回</td>
            <td class="right"></td>
          </tr>
        </a>
      </table>
      <!-- D菜单的结束 -->
    </td>
    <%
    }
    %>
    
        <td><span class=sepbtn></span></td>
        <td align="center" nowrap>
          <!-- D菜单的开始 -->
          <table cellspacing="0" cellpadding="0" class="root" menu="skinMenu">
            <tr>
              <td class="left"></td>
			  <td class="icon"><img src="<%=sThemeImagePath%>mac.gif" width="18" height="18"></td>
              <td class="middle"  nowrap >风格</td>
              <td class="right"></td>
            </tr>
          </table>
          <!-- D菜单的结束 -->
        </td>
    <%
    
    Collection colWorkplacePortal = (Collection)session.getAttribute("colPortalId");
    
    if(colWorkplacePortal != null && !colWorkplacePortal.isEmpty()) {
    
    %>
    <td><span class=sepbtn></span></td>
    <td align="center" nowrap>
      <!-- 返回我的工作台的开始 -->
      <table cellspacing="0" cellpadding="0" class="root" menu="backindex">
        <a href="<%=ctxp%>/index.jsp" target="_parent">
          <tr >
            <td class="left"></td>
            <td class="icon"><img src="<%=sThemeImagePath%>home.gif"></td>
            <td class="middle"  nowrap >我的工作台</td>
            <td class="right"></td>
          </tr>
        </a>
      </table>
      <!-- 返回我的工作台的结束 -->
      <%
      }
      %>
    </td>
    <td><span class=sepbtn></span></td>
    <td align="center" nowrap>
      
      <!-- 返回首页的开始 -->
      <table cellspacing="0" cellpadding="0" class="root" menu="backindex">
        <a href="#" onclick="openChat()">
          <tr >
            <td class="left"></td>
            <td class="icon"><img src="<%=sThemeImagePath%>home.gif"></td>
            <td class="middle"  nowrap >易讯消息</td>
            <td class="right"></td>
          </tr>
        </a>
      </table>
      <!-- 返回首页的结束 -->
    </td>
    <td><span class=sepbtn></span></td>
    <td align="center" nowrap>
      
      <!-- 返回首页的开始 -->
      <table cellspacing="0" cellpadding="0" class="root" menu="backindex">
        <a href="<%=ctxp%>/homepage/homepage.jsp?infoissue=true&pagefrom=oa" target="_parent">
          <tr >
            <td class="left"></td>
            <td class="icon"><img src="<%=sThemeImagePath%>home.gif"></td>
            <td class="middle"  nowrap >首页</td>
            <td class="right"></td>
          </tr>
        </a>
      </table>
      <!-- 返回首页的结束 -->
    </td>
    <%
    if(!bAccreditLogin){
    %>
    <td><span class=sepbtn></span></td>
    <td align="center" nowrap>
      <!-- 退出系统的开始 -->
      <table cellspacing="0" cellpadding="0" class="root" menu="backexit">
        <a href="<%=ctxp%>/logout.do" target="_parent">
          <tr>
            <td class="left"></td>
            <td class="icon"><img src="<%=sThemeImagePath%>qd_top_dl.gif"></td>
            <td  nowrap class="middle">退出</td>
            <td class="right"></td>
          </tr>
        </a>
        
      </table>
      <!-- 退出系统的结束 -->
    </td>
    <%
    }
    %>
    <td class="menuBar_right">&nbsp;</td>
  </tr>
</table>
<!-- 一级菜单的结束 -->
<script language='javascript'>
if (mtDropDown.isSupported()) {
var ms = new mtDropDownSet(mtDropDown.direction.down, 0, 0, mtDropDown.reference.bottomLeft);
<%
//这里输入 第2级菜单
// 因为这个JS生成的菜单比较特殊，必须按照一定的顺序所以在这里就比较麻烦点
// 具体顺序请参照 /themes/newstyle/media/mt_dropdown_content.js 的顺序，那个是输出后的JS
//------------------------ 2 -------------------------------
enuChild=tree.getRoot().children();
while(enuChild.hasMoreElements()) {
  node=(TreeNode)enuChild.nextElement();
  info=(FunctionInfo)node.getUserObject();
  
  if("menu".equals(info.getType())||"".equals(Function.normalizeString(info.getType())))    //如果类型是菜单类型，则取得子菜单
  {
    %>
var <%=info.getId()%> = ms.addMenu(document.getElementById("<%=info.getId()%>"));
  <%
  Enumeration enuSubNode=node.children();
  while(enuSubNode.hasMoreElements()) {
    TreeNode childNode=(TreeNode)enuSubNode.nextElement();
    FunctionInfo childInfo=(FunctionInfo)childNode.getUserObject();
    if(childInfo.getIsleaf()==1 && "menu".equals(childInfo.getType())){
      out.print(info.getId()+".addItem(\""+childInfo.getName()+"\",\""+ctxp+"/menucontroller.do?functionid="+childInfo.getId()+"\",\"contentFrame\");");
    }else{
    if(!"menu".equals(childInfo.getType())){
    out.print(info.getId()+".addItem(\""+childInfo.getName()+"\",\""+ctxp+"/menucontroller.do?functionid="+childInfo.getId()+"\",\"contentFrame\");");
    }else{
       out.print(info.getId()+".addItem(\""+childInfo.getName()+"\",\"\",\"\");");
       }
    }
  }
  }
}
//------------------------ 2  end -------------------------------
//如果需要有第四级菜单就拷贝这个方法，继续扩展下一段
//------------------------ 3  begin -------------------------------
enuChild=tree.getRoot().children();
while(enuChild.hasMoreElements()) {
  node=(TreeNode)enuChild.nextElement();
  info=(FunctionInfo)node.getUserObject();
  
  if("menu".equals(info.getType())||"".equals(Function.normalizeString(info.getType())))    //如果类型是菜单类型，则取得子菜单
  {
    Enumeration enuSubNode=node.children();
    int ko = 0;
    while(enuSubNode.hasMoreElements()) {
      TreeNode childNode=(TreeNode)enuSubNode.nextElement();
      FunctionInfo childInfo=(FunctionInfo)childNode.getUserObject();
      
      if(childInfo.getIsleaf()==0 && "menu".equals(childInfo.getType())){
        out.print("var "+childInfo.getId()+" = "+info.getId()+".addMenu("+info.getId()+".items["+ko+"]); \n");
        Enumeration threeNode=childNode.children();
        while(threeNode.hasMoreElements()) {
          TreeNode threesubNode=(TreeNode)threeNode.nextElement();
          FunctionInfo threeInfo=(FunctionInfo)threesubNode.getUserObject();
          if("menu".equals(threeInfo.getType())){
            out.print(childInfo.getId()+".addItem(\""+threeInfo.getName()+"\",\""+ctxp+"/menucontroller.do?functionid="+threeInfo.getId()+"\",\"contentFrame\");");
          }
        }
      }
      ko++;
    }
  }
}
%>
// var menu1 = ms.addMenu(document.getElementById("menu1"));
//  menu1.addItem("- Office 97 Look (Default)","/ecomapp/themes/newstyle/index.jsp?style=office97","_parent"); 
 // menu1.addItem("- Duki","/ecomapp/themes/newstyle/index.jsp?style=Duki","_parent");
//  menu1.addItem("- WNX","/ecomapp/themes/newstyle/index.jsp?style=wnx","_parent");
 // menu1.addItem("- Blue&nbsp;&nbsp;蓝色魅力","/ecomapp/themes/newstyle/index.jsp?style=blue","_self");
 // menu1.addItem("- fcblt&nbsp;&nbsp;芳草碧连天","/ecomapp/themes/newstyle/index.jsp?style=fcblt","_self");
 // menu1.addItem("- MAC&nbsp;&nbsp;(big)-&nbsp;苹果风格","/ecomapp/themes/newstyle/index.jsp?style=mac","_self");
 // menu1.addItem("- Bluegem&nbsp;&nbsp;蓝色宝石","/ecomapp/themes/newstyle/index.jsp?style=bluegem","_self");
 // menu1.addItem("- Merry Christmas&nbsp;&nbsp;圣诞快乐","/ecomapp/themes/newstyle/index.jsp?style=Merry Christmas","_self");
 // menu1.addItem("- zsfb&nbsp;&nbsp;紫","/ecomapp/themes/newstyle/index.jsp?style=zsfb","_self");
 // menu1.addItem("- bluesky&nbsp;&nbsp;蓝蓝天空","/ecomapp/themes/newstyle/index.jsp?style=bluesky","_self");

  
mtDropDown.renderAll();
}
</script> 
<table cellspacing="0" cellpadding="0" class="menu" id="logoutAccredit">
</table>
<!-- 我的办公桌子菜单的结束 -->

<!-- 返回首页的开始 -->
<table cellspacing="0" cellpadding="0" class="menu" id="backindex">
</table>
<!-- 返回首页的结束 -->


<!-- 退出系统的开始 -->
<table cellspacing="0" cellpadding="0" class="menu" id="backexit" >
</table>
<!-- 退出系统的结束 -->


<!-- 消息开始 -->
<table cellspacing="0" cellpadding="0" class="menu" id="message" >
</table>
<!-- 消息结束 -->
<%@include file="/include/currentuserinfo.jsp"%>
<%@include file="/include/filepath.jsp"%>
<%
if(!bAccreditLogin){
%>
<iframe id="msg" name="msg" src="/messageretrievingservlet?interval=40&userid=<%=userid%>&style=<%=currentSkinCss%>" style=" width:0px; height:0px; " frameborder="0" scrolling="No"></iframe>
<%
}
%>

<!--添加图层提醒-->
<SCRIPT language=JavaScript>
    timePopup=5;
    var ns=(document.layers);
    var ie=(document.all);
    var w3=(document.getElementById && !ie);
    adCount=0;
    function initPopup()
    {
        if(!ns && !ie && !w3)
            return;
        if(ie)
           adDiv = document.all.lbplocation.style;
        else if(ns) adDiv=eval('document.layers["lbplocation"]');
        else if(w3) adDiv=eval('document.getElementById("lbplocation").style');
        if (ie||w3)
        {
            adDiv.visibility="visible";
        }
        else
        {
            adDiv.visibility ="show";
        }
        showPopup();
    }
    function showPopup()
    {
        if(adCount<timePopup*10)
        {
            adCount+=1;
            if (ie)
            {
                documentWidth  =document.body.offsetWidth/2+document.body.scrollLeft-20;
                documentHeight =document.body.offsetHeight/2+document.body.scrollTop-20;
            }
            else if (ns)
            {
                documentWidth=window.innerWidth/2+window.pageXOffset-20;documentHeight=window.innerHeight/2+window.pageYOffset-20;
            }
            else if (w3)
            {
                documentWidth=self.innerWidth/2+window.pageXOffset-20;documentHeight=self.innerHeight/2+window.pageYOffset-20;
            }
            //adDiv.left=documentWidth-250;
            //adDiv.top =documentHeight-150;
            adDiv.left=document.body.offsetWidth-180;
            adDiv.top =0;
            setTimeout("showPopup()",100);
        }
        else closePopup();
    }

    function closePopup()
    {
       adCount=0;
        if (ie||w3)
            document.all.lbplocation.style.visibility="hidden";
        else
            adDiv.visibility ="hide";
    }

    function showAlert(num)
    {
       initPopup();
       document.all.num.value=num;
       //document.all.atd.value=num;
    }

    function openMessageList()
    {
        parent.contentFrame.open('<%=ctxp%>/message/messagelist.jsp?userid=<%=userid%>&status=<%=IAlertStatus.ALERT_LAYER%>','contentFrame');
        closePopup();
    }


                    </SCRIPT>

<%
DB db = DBFactory.getDBInstance();
AlertProfile profile = null;
try {
  IAlertProfileManager alertProfileManager = new DefaultAlertProfileManager(db);
  profile = alertProfileManager.getProfile(userid);
} catch(Exception e) {
} finally {
  if(db!=null) {
    db.close();
    db = null;
  }
}

%>

<div id=lbplocation style="left: 55%; position: absolute; top: 50px; visibility: hidden; width: 200;">
  <table class="Titus">
    <tbody>
      <tr>
        <td class="gao"></td>
      </tr>
      <tr>
        
        <td ><table border="0" cellspacing="0" cellpadding="0" class="xx">
            <tr>
              <td class="xjl"></td>
              <td  class="Titus_font_1">信息提示</td>
              <td >&nbsp;&nbsp;</td>
              <td> <a href="javascript:openMessageList();"  title=从这里开始进入消息列表><img src="<%=ctxp%>/message/images/<%=profile.getImage()%>" /></a></td>
            </tr>
        </table></td>
      </tr>
      <tr>
        
        <td class="Titus_font_2">您有  <input name="num" type="text" class="input_Titus" id="num" size="3" />条新消息</td>
      </tr>
      <tr>
        
        <td align=middle vAlign=center class="Titus_5">(此视窗将于 5 秒后自动关闭)</td>
      </tr>
    </tbody>
  </table>
  
</div>
